<template>
  <div class="app-container">
    <div class="head">
      <img src="@/assets/img/Layout/position.png" />
      <p class="see-block">产品编辑</p>
    </div>
    <div class="view-container">
      <el-row class="status-title">
        <el-col class="mr20 width100">
          <el-button
            class="btn-success width100"
            type="primary"
            @click="submitForm(1)"
          >保存</el-button>
        </el-col>
        <el-col class="mr20 width100">
          <el-button
            class="btn-success width100"
            type="primary"
            @click="submitForm(2)"
          >提交</el-button>
        </el-col>
        <el-col :span="10" class="status-container">
          <div class="status-item">
            <span class="active">草稿</span>
            <span>待审核</span>
            <span>已审核</span>
            <span>拒绝</span>
          </div>
        </el-col>
      </el-row>
      <el-form ref="form" :model="form" label-width="140px" class="mt30">
        <ul class="tabs" style="width:440px;">
          <li @click="current = 0" :class="{ active: current === 0 }">基本信息</li>
          <li @click="current = 1" :class="{ active: current === 1 }">采购信息</li>
          <li @click="current = 2" :class="{ active: current === 2 }">销售信息</li>
          <li @click="current = 3" :class="{ active: current === 3 }">库存设置</li>
        </ul>
        <div v-show="current === 0">
          <el-row>
            <el-col :span="8">
              <el-form-item label="产品编码:" prop="productCode">
                <el-input v-model="form.productCode" placeholder="系统自动生成" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="产品名称:" prop="productName" class="icon-star">
                <el-input v-model="form.productName" placeholder="请输入产品名称" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="简称:" prop="shortName">
                <el-input v-model="form.shortName" placeholder="请输入简称" />
              </el-form-item>
            </el-col>
            <el-col :span="16">
              <el-form-item label="产品图片:">
                <el-upload
                  action="#"
                  :file-list="form.shareFiles"
                  list-type="picture-card"
                  :on-change="onUploadType"
                  :auto-upload="false"
                  :limit="9"
                  accept=".jpg,.jpeg,.png,.gif,.bmp,.JPG,.JPEG,.PNG,.GIF,.BMP"
                  :on-exceed="onExceed"
                  ref="fileUpload"
                >
                  <i slot="default" class="el-icon-plus"></i>
                  <div slot="file" slot-scope="{file}">
                    <img class="el-upload-list__item-thumbnail" :src="file.fileUrl" alt="">
                    <span class="el-upload-list__item-actions">
                      <span
                        class="el-upload-list__item-delete"
                        @click="onRemove(file)"
                      >
                        <i class="el-icon-delete"></i>
                      </span>
                    </span>
                  </div>
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="英文名称:" prop="enName">
                <el-input v-model="form.enName" placeholder="请输入英文名称" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="助记码:" prop="mnemonicCode">
                <el-input v-model="form.mnemonicCode" placeholder="请输入助记码" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="成本核算:" prop="costAccounting">
                <el-input v-model="form.costAccounting" placeholder="请输入成本核算" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="版本号:" prop="version">
                <el-input v-model="form.version" placeholder="自动生成版本号" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="产品属性:" prop="productProperties" class="icon-star">
                <el-select v-model="form.productProperties" placeholder="请选择" style="width:100%;" @change="onChangeProductProperties">
                  <el-option label="外购" value="1">外购</el-option>
                  <el-option label="自产" value="2">自产</el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="价格类型:" prop="priceType" class="icon-star">
                <el-select v-model="form.priceType" placeholder="请选择" style="width:100%;">
                  <el-option label="未税单价" value="0">未税单价</el-option>
                  <el-option label="含税单价" value="1">含税单价</el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="单位:" prop="unit">
                <el-input v-model="form.unit" placeholder="请输入单位" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="是否启用批次:" prop="enableBatches">
                <el-select v-model="form.enableBatches" placeholder="请选择" style="width:100%;" :disabled="form.productProperties == 2">
                  <el-option label="启用" value="0">启用</el-option>
                  <el-option label="禁用" value="1">禁用</el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="是否启用扫码:" prop="serialNumber">
                <el-select v-model="form.serialNumber" placeholder="请选择" style="width:100%;" :disabled="form.productProperties == 2">
                  <el-option label="启用" value="0">启用</el-option>
                  <el-option label="禁用" value="1">禁用</el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="产品分类:" prop="productClassification">
                <treeselect v-model="form.productClassification" :options="productListOptions" :normalizer="productNormal" placeholder="选择产品分类" noOptionsText="暂无数据" @select="changeSelect" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="品牌:" prop="brand">
                <el-select v-model="form.brand" placeholder="请选择" style="width:100%;">
                  <el-option v-for="(item,index) of brandArr" :key="index" :label="item.brandName" :value="item.brandName"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <!-- 规格 -->
          <el-row v-if="form.objectList && form.objectList.length > 0 || form.objectList == null">
            <el-col :span="8">
              <el-form-item label="规格名称:">
                <el-button class="btn-success width120" type="primary" @click="addPrivateSpec()">添加新规格</el-button>
              </el-form-item>
            </el-col>
          </el-row>
          <div v-for="(attr, index) in objectList" :key="index">
            <el-row >
              <el-col :span="8">
                <el-form-item label="规格名称">
                  <el-input v-model="attr.title" placeholder="请输入规格名称" :disabled="attr.isDisabled" />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item>
                  <el-button v-if="attr.isDisabled == false" class="btn-delete width100" type="primary" @click="delPrivateSpec(index)">删除规格</el-button>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="16">
                <el-form-item label="规格项">
                  <el-tag v-for="tag in attr.value" :key="tag" closable :disable-transitions="false" @close="handleClose(tag, attr)" class="btn-tag">
                    {{ tag }}
                  </el-tag>
                  <el-input
                    class="width100"
                    v-if="attr.inputVisible"
                    v-model="attr.inputValue"
                    :ref="`saveTagInput${index}`"
                    size="small"
                    @keyup.enter.native="handleInputConfirm(attr.inputValue, attr)"
                    @blur="handleInputConfirm(attr.inputValue, attr)"
                  >
                  </el-input>
                  <el-button v-else class="btn-success" type="primary" size="small" @click="showInput(attr, index)">+ 添加</el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-row class="mb30" v-if="tableShow">
            <el-col :span="24">
              <el-table :data="tableColumnList.tableBodyList">
                  <el-table-column :label="item.propName" :property="item.prop" v-for="item in tableColumnList.tableHeaderList" :key="item.prop" align="center" fixed="left">
                    <template slot-scope="scope">
                      <span>{{ scope.row[scope.column.property] }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="SKU编码" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.specificationCode" placeholder="系统自动生成" disabled></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="销售价" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.sellingPrice" @blur="val => priceValidation(val, 'skuSellingPrice', scope.row)"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="采购价" align="center" v-if="form.productProperties == '1'">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.purchasePrice" @blur="val => priceValidation(val, 'skuPurchasePrice', scope.row)"></el-input>
                    </template>
                  </el-table-column>
                  <!-- <el-table-column label="成本价" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.costPrice" @blur="val => priceValidation(val, 'skuCostPrice', scope.row)"></el-input>
                    </template>
                  </el-table-column> -->
                  <el-table-column label="图片" align="center">
                    <template slot-scope="scope">
                      <el-upload
                        class="avatar-uploader"
                        action="#"
                        :auto-upload="false"
                        :on-change="(file) => {onUploadImg(file, scope.row)}"
                        accept=".jpg,.jpeg,.png,.gif,.bmp,.JPG,.JPEG,.PNG,.GIF,.BMP"
                        :show-file-list="false"
                      >
                        <img v-if="scope.row.imgUrl" :src="scope.row.imgUrl" width="50" height="50">
                        <i v-else class="el-icon-plus"></i>
                      </el-upload>
                    </template>
                  </el-table-column>
                  <!-- <el-table-column label="品牌" align="center">
                    <template slot-scope="scope">
                      <el-select v-model="scope.row.brandId" placeholder="请选择" style="width:100%;">
                        <el-option v-for="(item,index) of brandArr" :key="index" :label="item.brandName" :value="item.id"></el-option>
                      </el-select>
                    </template>
                  </el-table-column> -->
                  <el-table-column label="是否启用批次" align="center">
                    <template slot-scope="scope">
                      <el-select v-model="scope.row.enableBatches" placeholder="请选择" style="width:100%;" @change="val => onChangeEdit(val, scope.row)" :disabled="form.productProperties == 2">
                        <el-option label="启用" value="0">启用</el-option>
                        <el-option label="禁用" value="1">禁用</el-option>
                      </el-select>
                    </template>
                  </el-table-column>
                  <el-table-column label="是否启用扫码" align="center">
                    <template slot-scope="scope">
                      <el-select v-model="scope.row.isSerial" placeholder="请选择" style="width:100%;" @change="val => onChangeEdit(val, scope.row)" :disabled="form.productProperties == 2">
                        <el-option label="启用" value="0">启用</el-option>
                        <el-option label="禁用" value="1">禁用</el-option>
                      </el-select>
                    </template>
                  </el-table-column>
                  <el-table-column label="描述" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.description"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="产品标识" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.productIdentification"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="箱规" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.standardBoxGauge" @blur="standardBoxGauge(scope.row)"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="箱码标识" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.boxCodeIdentification"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="大码规格" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.largeSizeSpecifications" @blur="largeSizeSpecifications(scope.row)"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="大码标识" align="center">
                    <template slot-scope="scope">
                      <el-input v-model="scope.row.largeSizeIdentification"></el-input>
                    </template>
                  </el-table-column>
              </el-table>
            </el-col>
          </el-row>
          <!--  -->
          <el-row>
            <el-col :span="8">
              <el-form-item label="产品注册证号:" prop="registrationNumber">
                <el-input v-model="form.registrationNumber" placeholder="请输入产品注册证号" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="有效天数:" prop="validDate">
                <el-input v-model="form.validDate" placeholder="请输入有效天数" @input="val => inputValidation(val, 'validDate')" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="可组装/拆卸:" prop="assembly">
                <el-select v-model="form.assembly" placeholder="请选择" style="width:100%;">
                  <el-option label="是" value="0">是</el-option>
                  <el-option label="否" value="1">否</el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <!-- <el-col :span="8">
              <el-form-item label="成本价:" prop="costPrice" class="icon-star">
                <el-input v-model="form.costPrice" placeholder="请输入成本价" @blur="val => priceValidation(val, 'costPrice')" />
              </el-form-item>
            </el-col> -->
            <!-- <el-col :span="8" v-if="JSON.stringify(tableColumnList.tableBodyList) == '[]'">
              <el-form-item label="箱规:" prop="boxGauge" class="icon-star">
                <el-input v-model="form.boxGauge" placeholder="请输入箱规" @input="val => inputValidation(val, 'boxGauge')" />
              </el-form-item>
            </el-col> -->
          </el-row>
          <!-- <el-row>
            <el-col :span="8">
              <el-form-item label="单位:" prop="unit">
                <el-input v-model="form.unit" placeholder="请输入单位" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="箱规:" prop="boxGauge" class="icon-star">
                <el-input v-model="form.boxGauge" placeholder="请输入箱规" @input="val => inputValidation(val, 'boxGauge')" />
              </el-form-item>
            </el-col>
          </el-row> -->
        </div>
        <div v-show="current === 1">
          <el-row>
            <el-col :span="8">
              <el-form-item label="采购价格:" prop="purchasePrice" class="icon-star">
                <el-input v-model="form.purchasePrice" placeholder="请输入采购价格" @blur="val => priceValidation(val, 'purchasePrice')" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="采购最高限价:" prop="purchasePriceMax">
                <el-input v-model="form.purchasePriceMax" placeholder="请输入采购最高限价" @blur="val => priceValidation(val, 'purchasePriceMax')" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="采购限额数量:" prop="purchaseNum">
                <el-input v-model="form.purchaseNum" placeholder="请输入采购限额数量" @input="val => inputValidation(val, 'purchaseNum')" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="采购限额金额:" prop="purchasePriceMin">
                <el-input v-model="form.purchasePriceMin" placeholder="请输入采购限额金额" @blur="val => priceValidation(val, 'purchasePriceMin')" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="采购提前期（天）:" prop="procurementLeadTime">
                <el-input v-model="form.procurementLeadTime" placeholder="请输入采购提前期（天）" @input="val => inputValidation(val, 'procurementLeadTime')" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="下单提前期（天）:" prop="orderLeadTime">
                <el-input v-model="form.orderLeadTime" placeholder="请输入下单提前期（天）" @input="val => inputValidation(val, 'orderLeadTime')" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="最小起订量:" prop="minimumOrderQuantity">
                <el-input v-model="form.minimumOrderQuantity" placeholder="请输入最小起订量" @input="val => inputValidation(val, 'minimumOrderQuantity')" @blur="val => compareSize(val, 'minimumOrderQuantity')" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="最大数量限制:" prop="maximumOrderQuantity">
                <el-input v-model="form.maximumOrderQuantity" placeholder="请输入最大数量限制" @input="val => inputValidation(val, 'maximumOrderQuantity')" @blur="val => compareSize(val, 'maximumOrderQuantity')" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="采购员:" prop="buyer">
                <el-input v-model="form.buyer" placeholder="请输入采购员" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="采购供应商:" prop="purchasingSuppliers">
                <el-autocomplete
                  style="width:100%;"
                  v-model="form.purchasingSuppliers"
                  :fetch-suggestions="searchSupplier"
                  placeholder="请输入采购供应商"
                ></el-autocomplete>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
        <div v-show="current === 2">
          <el-row>
            <el-col :span="8">
              <el-form-item label="销售价格:" prop="sellingPrice" class="icon-star">
                <el-input v-model="form.sellingPrice" placeholder="请输入销售价格" @blur="val => priceValidation(val, 'sellingPrice')" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="配送天数:" prop="deliveryDays">
                <el-input v-model="form.deliveryDays" placeholder="请输入配送天数" @input="val => inputValidation(val, 'deliveryDays')" />
              </el-form-item>
            </el-col>
          </el-row>
        </div>
        <div v-show="current === 3">
          <el-row>
            <el-col :span="8">
              <el-form-item label="最大安全库存:" prop="maximumStock" class="icon-star">
                <el-input v-model="form.maximumStock" placeholder="请输入最大安全库存" @input="val => inputValidation(val, 'maximumStock')" @blur="val => compareSize(val, 'maximumStock')" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="最小安全库存:" prop="minimumStock" class="icon-star">
                <el-input v-model="form.minimumStock" placeholder="请输入最小安全库存" @input="val => inputValidation(val, 'minimumStock')" @blur="val => compareSize(val, 'minimumStock')" />
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
import { editProduct, detailProduct, editProductSku } from "@/api/system/basedata/product/product";
import { listSupplier } from "@/api/system/basedata/supplier/supplier";
import { listBrand } from "@/api/system/basedata/brand/brand";
import { listToAddProductList, checkProductList } from "@/api/system/basedata/productlist/productlist";
import { uploadImg } from "@/api/system/upload/upload";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
  name: "productEdit",
  components: { Treeselect },
  data(){
    return {
      current: 0,
      form: {
        productCode: '', // 产品编码
        productName: '', // 产品名称
        shortName: '', // 简称
        shareFiles: [], // 产品图片
        enName: '', // 英文名称
        mnemonicCode: '', // 助记码
        costAccounting: '', // 成本核算
        version: '', // 版本号
        productSpecificationsList: [], // 规格
        brand: '', // 品牌
        productClassification: undefined, // 货品分类
        assembly: '', // 可组装/拆卸
        validDate: '', // 有效天数
        enableBatches: '', // 批次号
        serialNumber: '', // 序列号
        costPrice: '', // 成本价
        productProperties: '', // 产品属性
        priceType: '', // 价格类型
        unit: '', // 单位
        registrationNumber: '', // 产品注册证号
        boxGauge: '', // 箱规
        purchasePrice: '', // 采购价格
        purchasePriceMax: '', // 采购最高限价
        purchaseNum: '', // 采购限额数量
        purchasePriceMin: '', // 采购限额金额
        procurementLeadTime: '', // 采购提前期（天）
        orderLeadTime: '', // 下单提前期（天）
        minimumOrderQuantity: undefined, // 最小起订量
        maximumOrderQuantity: undefined, // 最大数量限制
        buyer: '', // 默认采购员
        purchasingSuppliers: '', // 采购供应商
        sellingPrice: '', // 销售价格
        deliveryDays: '', // 配送天数
        maximumStock: undefined, // 最大安全库存
        minimumStock: undefined // 最小安全库存
      },
      brandArr: [],
      supplierList: [],
      productListOptions: [],
      // 规格
      objectList: [],
      tableColumnList: {
        tableHeaderList: [],
        tableBodyList: []
      },
      tableShow: false,
      id: '',
    }
  },
  created() {
    this.id = this.$route.query.id
    this.getDetailData()
    this.getBrand()
    this.getSupplier()
    this.getProductList()
  },
  computed: {
    // 计算规格
    calculateAttribute() {
      // 初始化
      let obj = {}
      this.objectList.forEach((item) => {
        // 判断规格名不能是数字
        if (/^[1-9]\d*$|^0$/.test(item.title) == false) {
          obj[item.title] = item.value
        }else{
          item.title = ''
          this.$modal.msgError('规格名不能是数字！')
        }
      })
      return obj
    }
  },
  watch: {
    // 监听规格数据
    calculateAttribute(newVal) {
      let cloneNewVal = JSON.parse(JSON.stringify(newVal))
      let attrName = [] //规格名数组
      let attrValue = [] //规格值数组
      let title1 = [] // 
      let value1 = []
      let title2 = []
      let value2 = []
      let specificationName = []
      for (let key in cloneNewVal) {
        attrName.push(key)
        title1.push('title1')
        value1.push('value1')
        title2.push('title2')
        value2.push('value2')
        specificationName.push('specificationName')
        attrValue.push(cloneNewVal[key])
      }
      // 表格内容数据（笛卡尔积算法）
      let finalArr = this.cartesianProductOf(...attrValue)
      let tableObj = {
        tableBodyList: [],
        tableHeaderList: []
      }
      // 表格内容
      tableObj.tableBodyList = finalArr.map((item) => {
        let obj = {
          id: '',
          specificationCode: '',
          specificationName: '',
          productBasicCode: '',
          sellingPrice: '',
          costPrice: '',
          purchasePrice: '',
          imgUrl: '',
          stock: '',
          // brandId: '',
          checkStatus: '',
          isSerial: this.form.serialNumber, // 0 是 1 否
          enableBatches: this.form.enableBatches, // 0 是 1 否
          description: '',
          productIdentification: '',
          standardBoxGauge: this.form.boxGauge,
          boxCodeIdentification: '',
          largeSizeIdentification: '',
          largeSizeSpecifications: ''
        }
        for (let i = 0; i < item.length; i++) {
          let skuTableArr = Object.keys(newVal)
          obj[attrName[i]] = item[i]
          obj[title1[i]] = skuTableArr[0]
          obj[title2[i]] = skuTableArr[1] ? skuTableArr[1] : ''
          obj[value1[i]] = item[0]
          obj[value2[i]] = item[1] ? item[1] : ''
          obj[specificationName[i]] = obj[title1[i]] + obj[value1[i]] + obj[title2[i]] + obj[value2[i]]
        }
        return obj
      })
      let a = tableObj.tableBodyList
      let b = this.form.productSpecificationsList
      for(let item of b){
        // console.log(item)
        if(item.value1 == null && item.value2 == null){
          a[0].id = item.id
          a[0].specificationCode = item.specificationCode
          a[0].productBasicCode = item.productBasicCode
          a[0].sellingPrice = item.sellingPrice
          a[0].costPrice = item.costPrice
          a[0].purchasePrice = item.purchasePrice
          a[0].imgUrl = item.imgUrl
          // a[0].brandId = item.brandId
          a[0].isSerial = item.isSerial
          a[0].checkStatus = item.checkStatus
          a[0].enableBatches = item.enableBatches
          a[0].description = item.description
          a[0].productIdentification = item.productIdentification
          a[0].standardBoxGauge = item.standardBoxGauge
          a[0].boxCodeIdentification = item.boxCodeIdentification
          a[0].largeSizeIdentification = item.largeSizeIdentification
          a[0].largeSizeSpecifications = item.largeSizeSpecifications
        }else{
          if(item.value2 == ''){
            let index = a.findIndex(e => e.value1 === item.value1)
            // console.log(index)
            if(index > -1){
              a[index].id = item.id
              a[index].specificationCode = item.specificationCode
              a[index].productBasicCode = item.productBasicCode
              a[index].sellingPrice = item.sellingPrice
              a[index].costPrice = item.costPrice
              a[index].purchasePrice = item.purchasePrice
              a[index].imgUrl = item.imgUrl
              // a[index].brandId = item.brandId
              a[index].isSerial = item.isSerial
              a[index].checkStatus = item.checkStatus
              a[index].enableBatches = item.enableBatches
              a[index].description = item.description
              a[index].productIdentification = item.productIdentification
              a[index].standardBoxGauge = item.standardBoxGauge
              a[index].boxCodeIdentification = item.boxCodeIdentification
              a[index].largeSizeIdentification = item.largeSizeIdentification
              a[index].largeSizeSpecifications = item.largeSizeSpecifications
            }else{
              a.push(item)
            }
          }else{
            let index = a.findIndex(e => e.value1 === item.value1 && e.value2 === item.value2)
            // console.log(index)
            if(index > -1){
              a[index].id = item.id
              a[index].specificationCode = item.specificationCode
              a[index].productBasicCode = item.productBasicCode
              a[index].sellingPrice = item.sellingPrice
              a[index].costPrice = item.costPrice
              a[index].purchasePrice = item.purchasePrice
              a[index].imgUrl = item.imgUrl
              // a[index].brandId = item.brandId
              a[index].isSerial = item.isSerial
              a[index].checkStatus = item.checkStatus
              a[index].enableBatches = item.enableBatches
              a[index].description = item.description
              a[index].productIdentification = item.productIdentification
              a[index].standardBoxGauge = item.standardBoxGauge
              a[index].boxCodeIdentification = item.boxCodeIdentification
              a[index].largeSizeIdentification = item.largeSizeIdentification
              a[index].largeSizeSpecifications = item.largeSizeSpecifications
            }else{
              a.push(item)
            }
          }
        }
      }
      // console.log(tableObj.tableBodyList)
      let arr = tableObj.tableBodyList.filter(item => item.specificationName !== '')
      // console.log(arr)
      this.tableColumnList.tableBodyList = arr //表格内容数据
      // 表头
      let skuTableArr = Object.keys(newVal)
      tableObj.tableHeaderList = skuTableArr.map((item) => {
        return {
          prop: item,
          propName: item
        }
      })
      this.tableColumnList.tableHeaderList = tableObj.tableHeaderList // 表头
    }
  },
  methods: {
    // 获取详情信息
    getDetailData() {
      detailProduct(this.id).then(res => {
        this.form = res.data
        this.form.productSpecificationsList = res.data.productSpecificationsList
        if(res.data.productSpecificationsList.length > 0){
          this.tableShow = true
        }
        if(res.data.objectList !== null){
          let arr = []
          res.data.objectList.map(item => {
            arr.push(Object.assign(
              {},item,{
                isDisabled: true,
                inputVisible: false,
                inputValue: ''
              }
            ))
          })
          this.objectList = arr
        }
        // this.getProductList()
      })
    },
    // 获取品牌
    getBrand(){
      listBrand(this.addDateRange({status: 0})).then(res => {
        this.brandArr = res.rows
      })
    },
    // 获取产品分类
    getProductList(){
      listToAddProductList().then(res => {
        this.productListOptions = this.handleTree(res.rows, "id")
      })
    },
    // 转换产品分类数据结构 
    productNormal(e) {
      if (e.children && !e.children.length) {
        delete e.children
      }
      return {
        id: e.id,
        label: e.sortName,
        children: e.children
      }
    },
    // 检测是否含有子集
    changeSelect(e){
      // console.log(e)
      checkProductList(e.id).then(res => {
        // console.log(res)
        if(res.code == 103){
          this.form.productClassification = undefined
          this.$modal.msgError(res.msg)
        }
      })
    },
    // 获取供应商
    getSupplier(){
      listSupplier(this.addDateRange({status: 1})).then((res) => {
        this.supplierList = res.rows
      })
    },
    // 供应商搜索
    searchSupplier(val, cb) {
      let list = []
      this.supplierList.map(item => {
        list.push(Object.assign(
          {},item,{
            value: item.name
          }
        ))
      })
      var arr = list
      var results = val ? arr.filter(this.createFilter(val)) : arr
      cb(results)
    },
    // 供应商匹配
    createFilter(val) {
      return (res) => {
        return (res.value.toLowerCase().indexOf(val.toLowerCase()) === 0)
      }
    },
    // 上传产品图片
    onUploadType(item){
      this.$modal.loading("正在上传")
      let formData = new FormData()
      let file = item.raw
      formData.append('file', file)
      uploadImg(formData).then(res => {
        this.$modal.closeLoading()
        this.$modal.msgSuccess("上传成功")
        this.form.shareFiles.push(res.data)
      })
    },
    onExceed(){
      this.$modal.msgError('图片上传不能超过9张!')
    },
    // 产品属性选择
    onChangeProductProperties(e){
      if(e == '2'){
        this.form.enableBatches = '0'
        this.form.serialNumber = '0'
        if(this.tableColumnList.tableBodyList.length > 0){
          this.tableColumnList.tableBodyList.forEach(i => {
            i.enableBatches = '0'
            i.isSerial = '0'
          })
        }
      }
    },
    // 删除
    onRemove(item){
      let uploadFiles = this.$refs['fileUpload'].uploadFiles
      let index = uploadFiles.indexOf(item)
      uploadFiles.splice(index, 1)
      const idx = this.form.shareFiles.findIndex(i => i.uid == item.uid)
      this.form.shareFiles.splice(idx, 1)
    },
    // 添加新规格
    addPrivateSpec(){
      if(this.objectList.length < 2){
        this.objectList.push({
          title: '',
          value: [],
          inputVisible: false,
          isDisabled: false,
          inputValue: ''
        })
      }else{
        this.$modal.msgError('只能添加2组规格!')
      }
    },
    // 删除规格
    delPrivateSpec(index) {
      this.objectList.splice(index, 1)
      if(this.objectList.length == 0){
        this.tableShow = false
      }
    },
    // 添加规格项
    showInput(attr, index) {
      attr.inputVisible = true
      this.$nextTick((_) => {
        this.$refs[`saveTagInput${index}`][0].$refs.input.focus()
      })
    },
    handleInputConfirm(val, attr) {
      if (val) {
        let a = this.objectList[0].value.some(item => {
          return item == val
        })
        if(this.objectList[1] !== undefined && a == false){
          let b = this.objectList[1].value.some(item => {
            return item == val
          })
          // console.log(b)
          if(b == false){
            attr.value.push(val)
          }else{
            this.$modal.msgError('规格项已存在！')
          }
        }else{
          // console.log(a)
          if(a == false){
            attr.value.push(val)
          }else{
            this.$modal.msgError('规格项已存在！')
          }
        }
      }
      attr.inputVisible = false
      attr.inputValue = ''
      this.tableShow = true
    },
    // 删除规格项
    handleClose(tag, item) {
      if(this.form.productSpecificationsList.length > 0){
        console.log(this.form.productSpecificationsList)
        let arr = this.form.productSpecificationsList.some(item => {
          return item.value1 == tag || item.value2 == tag
        })
        // console.log(arr)
        if(arr == true){
          this.$modal.msgError('规格项已生成不能删除！')
        }else{
          item.value.splice(item.value.indexOf(tag), 1)
        }
      }else{
        item.value.splice(item.value.indexOf(tag), 1)
      }
    },
    // 笛卡尔积算法
    cartesianProductOf(...args) {
      return args.reduce(
        (total, current) => {
          let ret = []
          total.forEach((a) => {
            current.forEach((b) => {
              ret.push(a.concat([b]))
            })
          })
          return ret
        },
        [[]]
      )
    },
    // 上传规格图片
    onUploadImg(item, e){
      this.$modal.loading("正在上传")
      let formData = new FormData()
      let file = item.raw
      formData.append('file', file)
      uploadImg(formData).then(res => {
        this.$modal.closeLoading()
        this.$modal.msgSuccess("上传成功")
        e.imgUrl = res.data.fileUrl
      })
    },
    // CKU切换批次/序列号
    onChangeEdit(val, row){
      // console.log(val)
      if(row.id){
        editProductSku(row.id).then(res => {
          if(res.code == 103){
            this.$modal.msgError(res.msg)
            this.getDetailData()
          }
        })
      }
    },
    // 比较大小
    compareSize(val, type){
      if(type == 'minimumOrderQuantity'){
        if(this.form.maximumOrderQuantity !== undefined && this.form.maximumOrderQuantity !== null && this.form.maximumOrderQuantity !== ''){
          if(JSON.parse(this.form.minimumOrderQuantity) > JSON.parse(this.form.maximumOrderQuantity)){
            this.$modal.msgError('最小起订量不能大于最大数量！')
            this.form.minimumOrderQuantity = ''
          }
        }
      }else if(type == 'maximumOrderQuantity'){
        if(this.form.minimumOrderQuantity !== undefined && this.form.minimumOrderQuantity !== null && this.form.minimumOrderQuantity !== ''){
          if(JSON.parse(this.form.maximumOrderQuantity) < JSON.parse(this.form.minimumOrderQuantity)){
            this.$modal.msgError('最大数量不能小于最小起订量！')
            this.form.maximumOrderQuantity = ''
          }
        }
      }else if(type == 'maximumStock'){
        if(this.form.minimumStock !== undefined && this.form.minimumStock !== null && this.form.minimumStock !== ''){
          if(JSON.parse(this.form.maximumStock) < JSON.parse(this.form.minimumStock)){
            this.$modal.msgError('最大安全库存不能小于最小安全库存！')
            this.form.maximumStock = ''
          }
        }
      }else if(type == 'minimumStock'){
        if(this.form.maximumStock !== undefined && this.form.maximumStock !== null && this.form.maximumStock !== ''){
          if(JSON.parse(this.form.minimumStock) > JSON.parse(this.form.maximumStock)){
            this.$modal.msgError('最小安全库存不能大于最大安全库存！')
            this.form.minimumStock = ''
          }
        }
      }
    },
    // 规格箱规
    standardBoxGauge(row){
      if(/^[1-9]\d*$|^0$/.test(row.standardBoxGauge) == false){
        this.$modal.msgError('箱规必须是数字！')
        row.standardBoxGauge = ''
        return false
      }else{
        if(JSON.parse(row.standardBoxGauge) <= 0){
          row.standardBoxGauge = ''
          this.$modal.msgError('箱规必须大于0!')
        }
      }
    },
    // 大码规格
    largeSizeSpecifications(row){
      if(/^[1-9]\d*$|^0$/.test(row.largeSizeSpecifications) == false){
        this.$modal.msgError('大码规格必须是数字！')
        row.largeSizeSpecifications = ''
        return false
      }else{
        if(JSON.parse(row.largeSizeSpecifications) <= 0){
          row.largeSizeSpecifications = ''
          this.$modal.msgError('大码规格必须大于0!')
        }
      }
    },
    // 规则验证
    inputValidation(val, type){
      // 箱规
      if(/^[1-9]\d*$|^0$/.test(val) == false){
        if(type == 'boxGauge'){
          this.$modal.msgError('箱规必须是数字！')
          this.form.boxGauge = ''
        }else if(type == 'validDate'){
          this.$modal.msgError('有效天数必须是数字！')
          this.form.validDate = ''
        }else if(type == 'purchaseNum'){
          this.$modal.msgError('采购限额数量必须是数字！')
          this.form.purchaseNum = ''
        }else if(type == 'procurementLeadTime'){
          this.$modal.msgError('采购提前期必须是数字！')
          this.form.procurementLeadTime = ''
        }else if(type == 'orderLeadTime'){
          this.$modal.msgError('下单提前期必须是数字！')
          this.form.orderLeadTime = ''
        }else if(type == 'deliveryDays'){
          this.$modal.msgError('配送天数必须是数字！')
          this.form.deliveryDays = ''
        }else if(type == 'minimumOrderQuantity'){
          this.$modal.msgError('最小起订量必须是数字！')
          this.form.minimumOrderQuantity = ''
        }else if(type == 'maximumOrderQuantity'){
          this.$modal.msgError('最大数量限制必须是数字！')
          this.form.maximumOrderQuantity = ''
        }else if(type == 'maximumStock'){
          this.$modal.msgError('最大安全库存必须是数字！')
          this.form.maximumStock = ''
        }else if(type == 'minimumStock'){
          this.$modal.msgError('最小安全库存必须是数字！')
          this.form.minimumStock = ''
        }
        return false
      }else{
        if(Number(val) <= 0){
          if(type == 'boxGauge'){
            this.form.boxGauge = ''
            this.$modal.msgError('箱规必须大于0!')
          }else if(type == 'validDate'){
            this.form.validDate = ''
            this.$modal.msgError('有效天数必须大于0!')
          }else if(type == 'purchaseNum'){
            this.$modal.msgError('采购限额数量必须大于0!')
            this.form.purchaseNum = ''
          }else if(type == 'procurementLeadTime'){
            this.$modal.msgError('采购提前期必须大于0!')
            this.form.procurementLeadTime = ''
          }else if(type == 'orderLeadTime'){
            this.$modal.msgError('下单提前期必须大于0!')
            this.form.orderLeadTime = ''
          }else if(type == 'deliveryDays'){
            this.$modal.msgError('配送天数必须大于0!')
            this.form.deliveryDays = ''
          }else if(type == 'minimumOrderQuantity'){
            this.$modal.msgError('最小起订量必须大于0!')
            this.form.minimumOrderQuantity = ''
          }else if(type == 'maximumOrderQuantity'){
            this.$modal.msgError('最大数量限制必须大于0!')
            this.form.maximumOrderQuantity = ''
          }else if(type == 'maximumStock'){
            this.$modal.msgError('最大安全库存必须大于0!')
            this.form.maximumStock = ''
          }else if(type == 'minimumStock'){
            this.$modal.msgError('最小安全库存必须大于0!')
            this.form.minimumStock = ''
          }
        }
      }
    },
    // 价格验证
    priceValidation(val, type, row ){
      if(/^([1-9][0-9]*|0)((.\d{0,2})?)$/.test(val.target.value) == false){
        if(type == 'costPrice'){
          this.$modal.msgError('成本价必须为数字且最多保留小数点后两位！')
          this.form.costPrice = ''
        }else if(type == 'purchasePrice'){
          this.$modal.msgError('采购价格必须为数字且最多保留小数点后两位！')
          this.form.purchasePrice = ''
        }else if(type == 'purchasePriceMax'){
          this.$modal.msgError('采购最高限价必须为数字且最多保留小数点后两位！')
          this.form.purchasePriceMax = ''
        }else if(type == 'purchasePriceMin'){
          this.$modal.msgError('采购限额金额必须为数字且最多保留小数点后两位！')
          this.form.purchasePriceMin = ''
        }else if(type == 'sellingPrice'){
          this.$modal.msgError('销售价格必须为数字且最多保留小数点后两位！')
          this.form.sellingPrice = ''
        }else if(type == 'skuSellingPrice'){
          this.$modal.msgError('销售价必须为数字且最多保留小数点后两位！')
          row.sellingPrice = ''
        }else if(type == 'skuCostPrice'){
          this.$modal.msgError('成本价必须为数字且最多保留小数点后两位！')
          row.costPrice = ''
        }else if(type == 'skuPurchasePrice'){
          this.$modal.msgError('采购价必须为数字且最多保留小数点后两位！')
          row.purchasePrice = ''
        }
        return false
      }else{
        if(val.target.value == 0){
          if(type == 'costPrice'){
            this.$modal.msgError('成本价必须大于0!')
            this.form.costPrice = ''
          }else if(type == 'purchasePrice'){
            this.$modal.msgError('采购价格必须大于0!')
            this.form.purchasePrice = ''
          }else if(type == 'purchasePriceMax'){
            this.$modal.msgError('采购最高限价必须大于0!')
            this.form.purchasePriceMax = ''
          }else if(type == 'purchasePriceMin'){
            this.$modal.msgError('采购限额金额必须大于0!')
            this.form.purchasePriceMin = ''
          }else if(type == 'sellingPrice'){
            this.$modal.msgError('销售价格必须大于0!')
            this.form.sellingPrice = ''
          }
          // else if(type == 'skuSellingPrice'){
          //   this.$modal.msgError('销售价必须大于0!')
          //   row.sellingPrice = ''
          // }else if(type == 'skuCostPrice'){
          //   this.$modal.msgError('成本价必须大于0!')
          //   row.costPrice = ''
          // }else if(type == 'skuPurchasePrice'){
          //   this.$modal.msgError('采购价必须大于0!')
          //   row.purchasePrice = ''
          // }
        }
      }
    },
    // 提交数据
    submitForm(e) {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if(e == 1){
            // if(this.form.productCode == ''){
            //   this.$modal.msgError('产品编码不能为空！')
            // }else 
            if(this.form.productName == ''){
              this.$modal.msgError('产品名称不能为空！')
            }else{
              // 判断是否有规格
              let index = this.tableColumnList.tableBodyList.findIndex(item => {
                return item.specificationCode !== undefined || item.specificationCode !== null
              })
              if(index > -1){
                // 判断SKU编码是否存在
                // let coding = this.tableColumnList.tableBodyList.every(val => !!val.specificationCode)
                // if(coding == true){
                //   let list = []
                //   this.tableColumnList.tableBodyList.forEach(item => {
                //     list.push(item.specificationCode)
                //   })
                //   // 判断SKU编码是否重复
                //   let temp = this.common.isRepeat(list)
                //   if(temp == true){
                //     this.$modal.msgError('产品SKU编码不能重复！')
                //   }else{
                    this.form.productSpecificationsList = this.tableColumnList.tableBodyList
                    this.$modal.loading("正在保存")
                    editProduct(this.form).then(res=> {
                      if(res.code == 200){
                        this.getDetailData()
                        this.$modal.msgSuccess("保存成功")
                        this.$modal.closeLoading()
                      }else{
                        this.$modal.msgError(res.msg)
                        this.$modal.closeLoading()
                      }
                    })
                //   }
                // }else{
                //   this.$modal.msgError('产品SKU编码不能为空！')
                // }
              }else{
                this.$modal.loading("正在保存")
                editProduct(this.form).then(res=> {
                  if(res.code == 200){
                    this.getDetailData()
                    this.$modal.msgSuccess("保存成功")
                    this.$modal.closeLoading()
                  }else{
                    this.$modal.msgError(res.msg)
                    this.$modal.closeLoading()
                  }
                })
              }
            }
          }else{
            // if(this.form.productCode == ''){
            //   this.$modal.msgError('产品编码不能为空！')
            // }else 
            if(this.form.productName == ''){
              this.$modal.msgError('产品名称不能为空！')
            }else if(this.form.productProperties == ''){
              this.$modal.msgError('产品属性不能为空！')
            }else if(this.form.priceType == ''){
              this.$modal.msgError('价格类型不能为空！')
            }else if(JSON.stringify(this.tableColumnList.tableBodyList) == '[]'){
              this.$modal.msgError('产品规格不能为空！')
            }else if(this.form.maximumStock == ''){
              this.$modal.msgError('最大安全库存不能为空！')
            }else if(this.form.minimumStock == ''){
              this.$modal.msgError('最小安全库存不能为空！')
            }else{
              // if(JSON.stringify(this.tableColumnList.tableBodyList) == '[]'){
              //   if(this.form.boxGauge == '' || this.form.boxGauge == null){
              //     this.$modal.msgError('箱规不能为空！')
              //   }else{
              //     // 判断是否有规格
              //     let index = this.tableColumnList.tableBodyList.findIndex(item => {
              //       return item.specificationCode !== undefined || item.specificationCode !== null
              //     })
              //     if(index > -1){
              //       // 判断SKU编码是否存在
              //       // let coding = this.tableColumnList.tableBodyList.every(val => !!val.specificationCode)
              //       // if(coding == true){
              //       //   let list = []
              //       //   this.tableColumnList.tableBodyList.forEach(item => {
              //       //     list.push(item.specificationCode)
              //       //   })
              //       //   // 判断SKU编码是否重复
              //       //   let temp = this.common.isRepeat(list)
              //       //   if(temp == true){
              //       //     this.$modal.msgError('产品SKU编码不能重复！')
              //       //   }else{
              //           this.form.productSpecificationsList = this.tableColumnList.tableBodyList
              //           let arr = this.form
              //           arr.approvalStatus = 1
              //           arr.productStatus = 0
              //           editProduct(arr).then(res=> {
              //             if(res.code == 200){
              //               this.$refs.form.resetFields()
              //               this.$tab.closeOpenPage({ path: "/basedata/product/list" })
              //               this.$modal.msgSuccess("编辑成功")
              //             }else{
              //               this.form.productSpecificationsList = []
              //               this.$modal.msgError(res.msg)
              //             }
              //           })
              //       //   }
              //       // }else{
              //       //   this.$modal.msgError('产品SKU编码不能为空！')
              //       // }
              //     }else{
              //       // if(this.form.costPrice == ''){
              //       //   this.$modal.msgError('成本价格不能为空！')
              //       // }else 
              //       if(this.form.sellingPrice == ''){
              //         this.$modal.msgError('销售价格不能为空！')
              //       }
              //       // else if(this.form.purchasePrice == ''){
              //       //   this.$modal.msgError('采购价格不能为空！')
              //       // }
              //       else{
              //         if(this.form.productProperties == '1'){
              //           this.form.productSpecificationsList.push({
              //             // specificationCode: this.form.productCode,
              //             sellingPrice: this.form.sellingPrice,
              //             costPrice: this.form.costPrice,
              //             // purchasePrice: this.form.purchasePrice,
              //             isSerial: this.form.serialNumber,
              //             enableBatches: this.form.enableBatches,
              //             description: '',
              //             standardBoxGauge: this.form.boxGauge
              //           })
              //         }else{
              //           this.form.productSpecificationsList.push({
              //             // specificationCode: this.form.productCode,
              //             sellingPrice: this.form.sellingPrice,
              //             costPrice: this.form.costPrice,
              //             // purchasePrice: this.form.purchasePrice,
              //             isSerial: this.form.serialNumber,
              //             enableBatches: this.form.enableBatches,
              //             description: '',
              //             standardBoxGauge: this.form.boxGauge
              //           })
              //         }
              //         let arr = this.form
              //         arr.approvalStatus = 1
              //         arr.productStatus = 0
              //         editProduct(arr).then(res=> {
              //           if(res.code == 200){
              //             this.$refs.form.resetFields()
              //             this.$tab.closeOpenPage({ path: "/basedata/product/list" })
              //             this.$modal.msgSuccess("编辑成功")
              //           }else{
              //             this.form.productSpecificationsList = []
              //             this.$modal.msgError(res.msg)
              //           }
              //         })
              //       }
              //     }
              //   }
              // }else{
                // 判断是否有规格
                // let index = this.tableColumnList.tableBodyList.findIndex(item => {
                //   return item.specificationCode !== undefined || item.specificationCode !== null
                // })
                // if(index > -1){
                  // 判断SKU编码是否存在
                  // let coding = this.tableColumnList.tableBodyList.every(val => !!val.specificationCode)
                  // if(coding == true){
                  //   let list = []
                  //   this.tableColumnList.tableBodyList.forEach(item => {
                  //     list.push(item.specificationCode)
                  //   })
                  //   // 判断SKU编码是否重复
                  //   let temp = this.common.isRepeat(list)
                  //   if(temp == true){
                  //     this.$modal.msgError('产品SKU编码不能重复！')
                  //   }else{
                      this.form.productSpecificationsList = this.tableColumnList.tableBodyList
                      let arr = this.form
                      arr.approvalStatus = 1
                      arr.productStatus = 0
                      this.$modal.loading("正在提交")
                      editProduct(arr).then(res=> {
                        if(res.code == 200){
                          this.$refs.form.resetFields()
                          this.$tab.closeOpenPage({ path: "/basedata/product/list" })
                          this.$modal.msgSuccess("编辑成功")
                          this.$modal.closeLoading()
                        }else{
                          this.form.productSpecificationsList = []
                          this.$modal.msgError(res.msg)
                          this.$modal.closeLoading()
                        }
                      })
                  //   }
                  // }else{
                  //   this.$modal.msgError('产品SKU编码不能为空！')
                  // }
                // }else{
                //   // if(this.form.costPrice == ''){
                //   //   this.$modal.msgError('成本价格不能为空！')
                //   // }else 
                //   if(this.form.sellingPrice == ''){
                //     this.$modal.msgError('销售价格不能为空！')
                //   }
                //   // else if(this.form.purchasePrice == ''){
                //   //   this.$modal.msgError('采购价格不能为空！')
                //   // }
                //   else{
                //     if(this.form.productProperties == '1'){
                //       this.form.productSpecificationsList.push({
                //         // specificationCode: this.form.productCode,
                //         sellingPrice: this.form.sellingPrice,
                //         costPrice: this.form.costPrice,
                //         // purchasePrice: this.form.purchasePrice,
                //         isSerial: this.form.serialNumber,
                //         enableBatches: this.form.enableBatches,
                //         description: '',
                //         standardBoxGauge: this.form.boxGauge
                //       })
                //     }else{
                //       this.form.productSpecificationsList.push({
                //         // specificationCode: this.form.productCode,
                //         sellingPrice: this.form.sellingPrice,
                //         costPrice: this.form.costPrice,
                //         // purchasePrice: this.form.purchasePrice,
                //         isSerial: this.form.serialNumber,
                //         enableBatches: this.form.enableBatches,
                //         description: '',
                //         standardBoxGauge: this.form.boxGauge
                //       })
                //     }
                //     let arr = this.form
                //     arr.approvalStatus = 1
                //     arr.productStatus = 0
                //     editProduct(arr).then(res=> {
                //       if(res.code == 200){
                //         this.$refs.form.resetFields()
                //         this.$tab.closeOpenPage({ path: "/basedata/product/list" })
                //         this.$modal.msgSuccess("编辑成功")
                //       }else{
                //         this.form.productSpecificationsList = []
                //         this.$modal.msgError(res.msg)
                //       }
                //     })
                //   }
                // }
              // }
            }
          }
        }
      })
    }
  }
}
</script>

<style scoped>
::v-deep .el-upload--picture-card{
  border-color:#DCDFE6;
  background:#fff;
}
::v-deep .el-upload--picture-card:hover {
  border-color: #5ED4D4;
}
::v-deep .el-upload--picture-card:hover .el-icon-plus{
  color: #5ED4D4;
}

::v-deep .el-upload-list__item.is-ready {
  display: none;
}
.options {
  position: absolute;
  z-index:10;
  left:0;
  right:0;
}
.options li {
  height: 36px;
  line-height: 36px;
  cursor: pointer;
  border: 1px solid #ccc;
  border-top: 0px;
  text-indent: 12px;
  overflow: hidden;
}
.options li:hover {
  background: #f3f5f9;
  color: #000;
}
.options-head {
  border: 1px solid #ccc;
  background: #f3f5f9;
}
.options-item{
  background:#fff;
  overflow-y:scroll;
}
.all-shop {
  line-height: 36px;
  margin-left: 12px;
}
::v-deep .el-table__empty-block{
  display: none;
}
.avatar-uploader{
  width:52px;
  height:52px;
  margin:0 auto;
}
::v-deep .avatar-uploader .el-upload{
  width:52px;
  height:52px;
  line-height: 52px;
  border:1px solid #DCDFE6;
  cursor: pointer;
}
.avatar-uploader img{
  display: flex;
}
.del{
  color: #ff0000;
  cursor: pointer;
}
</style>